# 1 "FWlib/apt32f102_ifc.c"
# 1 "E:\\APT_Landscape_mode\\APT32F1023_New\\Source//"
# 1 "<built-in>"
# 1 "<command-line>"
# 1 "FWlib/apt32f102_ifc.c"
# 19 "FWlib/apt32f102_ifc.c"
# 1 "include/apt32f102_ifc.h" 1
# 23 "include/apt32f102_ifc.h"
# 1 "include/apt32f102.h" 1
# 23 "include/apt32f102.h"
# 1 "include/apt32f102_types_local.h" 1
# 63 "include/apt32f102_types_local.h"
typedef signed char S8_T;
typedef short S16_T;
typedef long S32_T;


typedef unsigned char U8_T;
typedef unsigned short U16_T;
typedef unsigned long U32_T;
typedef unsigned long long U64_T;


typedef float F32_T;
typedef double F64_T;


typedef U8_T B_T;
# 100 "include/apt32f102_types_local.h"
typedef enum {ENABLE = 1, DISABLE = !ENABLE} ClockStatus, FunctionalStatus;
typedef enum {ERROR = 0, SUCCESS = !ERROR} ErrorStatus;
typedef enum {RESET = 0, SET = !RESET} FlagStatus, ITStatus;




typedef volatile U32_T CSP_REGISTER_T;
typedef volatile U16_T CSP_REGISTER16_T;
typedef volatile U8_T CSP_REGISTER8_T;




typedef unsigned char UINT8;
typedef signed char SINT8;


typedef unsigned short UINT16;
typedef signed short SINT16;


typedef unsigned long UINT32;
typedef signed long SINT32;

typedef void VOID;
typedef signed char CHAR;
typedef unsigned char BOOL;
typedef signed long TIME_T;

typedef float SINGLE;



typedef double DOUBLE;

typedef struct
{
  unsigned bit0 : 1;
  unsigned bit1 : 1;
  unsigned bit2 : 1;
  unsigned bit3 : 1;
  unsigned bit4 : 1;
  unsigned bit5 : 1;
  unsigned bit6 : 1;
  unsigned bit7 : 1;
} REG8;

typedef struct
{
  unsigned bit0 : 1;
  unsigned bit1 : 1;
  unsigned bit2 : 1;
  unsigned bit3 : 1;
  unsigned bit4 : 1;
  unsigned bit5 : 1;
  unsigned bit6 : 1;
  unsigned bit7 : 1;
  unsigned bit8 : 1;
  unsigned bit9 : 1;
  unsigned bit10: 1;
  unsigned bit11: 1;
  unsigned bit12: 1;
  unsigned bit13: 1;
  unsigned bit14: 1;
  unsigned bit15: 1;
} REG16;






typedef char STRING_3[4];
typedef char STRING_5[6];
typedef char STRING_8[9];
typedef char STRING_10[11];
typedef char STRING_12[13];
typedef char STRING_16[17];
typedef char STRING_24[25];
typedef char STRING_30[31];
typedef char STRING_32[33];
typedef char STRING_48[49];
typedef char STRING_50[51];
typedef char STRING_60[61];
typedef char STRING_80[81];
typedef char STRING_132[133];
typedef char STRING_256[257];
typedef char STRING_512[513];
# 24 "include/apt32f102.h" 2
# 1 "include/apt32f102_ck801.h" 1
# 85 "include/apt32f102_ck801.h"
typedef enum IRQn
{

        ISR_Restart = -32,
        ISR_Misaligned_Access = -31,
        ISR_Access_Error = -30,
        ISR_Divided_By_Zero = -29,
        ISR_Illegal = -28,
        ISR_Privlege_Violation = -27,
        ISR_Trace_Exection = -26,
        ISR_Breakpoint_Exception = -25,
        ISR_Unrecoverable_Error = -24,
        ISR_Idly4_Error = -23,
        ISR_Auto_INT = -22,
        ISR_Auto_FINT = -21,
        ISR_Reserved_HAI = -20,
        ISR_Reserved_FP = -19,
        ISR_TLB_Ins_Empty = -18,
        ISR_TLB_Data_Empty = -17,

        INTC_CORETIM_IRQn = 0,
        INTC_TIME1_IRQn = 1,
        INTC_UART0_IRQn = 2,
        INTC_GPIOA2_IRQn = 8,
} IRQn_Type;


void INTC_Init(void);
void force_interrupt(IRQn_Type IRQn);

void CK_CPU_EnAllNormalIrq(void);
void CK_CPU_DisAllNormalIrq(void);
# 25 "include/apt32f102.h" 2




typedef struct {
 volatile unsigned int ReservedA[4];
 volatile unsigned int CORET_CSR;
 volatile unsigned int CORET_RVR;
 volatile unsigned int CORET_CVR;
 volatile unsigned int CORET_CALIB;
 volatile unsigned int ReservedB[56];
 volatile unsigned int ISER;
 volatile unsigned int ReservedC[15];
 volatile unsigned int IWER;
 volatile unsigned int ReservedD[15];
 volatile unsigned int ICER;
 volatile unsigned int ReservedE[15];
 volatile unsigned int IWDR;
 volatile unsigned int ReservedF[15];
 volatile unsigned int ISPR;
 volatile unsigned int ReservedG[31];
 volatile unsigned int ICPR;
 volatile unsigned int ReservedH[31];
 volatile unsigned int IABR;
 volatile unsigned int ReservedI[63];
 volatile unsigned int IPR[8];
 volatile unsigned int ReservedJ[504];
 volatile unsigned int ISR;
 volatile unsigned int IPTR;
} CSP_CK801_T;



typedef volatile struct {
 volatile unsigned int IDR ;
 volatile unsigned int CEDR ;
 volatile unsigned int SRR ;
 volatile unsigned int CMR ;
 volatile unsigned int CR ;
 volatile unsigned int MR ;
 volatile unsigned int FM_ADDR ;
 volatile unsigned int Reserved ;
 volatile unsigned int KR ;
 volatile unsigned int IMCR ;
 volatile unsigned int RISR ;
 volatile unsigned int MISR ;
 volatile unsigned int ICR ;
} CSP_IFC_T ;



typedef volatile struct {
 volatile unsigned int IDCCR;
 volatile unsigned int GCER;
 volatile unsigned int GCDR;
 volatile unsigned int GCSR;
 volatile unsigned int CKST;
 volatile unsigned int RAMCHK;
 volatile unsigned int EFLCHK;
 volatile unsigned int SCLKCR;
 volatile unsigned int PCLKCR;
 volatile unsigned int _RSVD0;
 volatile unsigned int PCER0;
 volatile unsigned int PCDR0;
 volatile unsigned int PCSR0;
 volatile unsigned int PCER1;
 volatile unsigned int PCDR1;
 volatile unsigned int PCSR1;
 volatile unsigned int OSTR;
 volatile unsigned int _RSVD1;
 volatile unsigned int _RSVD2;
 volatile unsigned int LVDCR;
 volatile unsigned int CLCR;
 volatile unsigned int PWRCR;
 volatile unsigned int PWRKEY;
 volatile unsigned int _RSVD3;
 volatile unsigned int _RSVD4;
 volatile unsigned int OPT1;
 volatile unsigned int OPT0;
 volatile unsigned int WKCR;
 volatile unsigned int _RSVD5;
 volatile unsigned int IMER;
 volatile unsigned int IMDR;
 volatile unsigned int IMCR;
 volatile unsigned int IAR;
 volatile unsigned int ICR;
 volatile unsigned int RISR;
 volatile unsigned int MISR;
 volatile unsigned int RSR;
 volatile unsigned int EXIRT;
 volatile unsigned int EXIFT;
 volatile unsigned int EXIER;
 volatile unsigned int EXIDR;
 volatile unsigned int EXIMR;
 volatile unsigned int EXIAR;
 volatile unsigned int EXICR;
 volatile unsigned int EXIRS;
 volatile unsigned int IWDCR;
 volatile unsigned int IWDCNT;
 volatile unsigned int IWDEDR;
 volatile unsigned int IOMAP0;
 volatile unsigned int IOMAP1;
 volatile unsigned int CINF0;
 volatile unsigned int CINF1;
 volatile unsigned int FINF0;
 volatile unsigned int FINF1;
 volatile unsigned int FINF2;
 volatile unsigned int _RSVD6;
 volatile unsigned int ERRINF;
 volatile unsigned int UID0 ;
 volatile unsigned int UID1 ;
 volatile unsigned int UID2 ;
 volatile unsigned int PWROPT;
 volatile unsigned int EVTRG;
 volatile unsigned int EVPS;
 volatile unsigned int EVSWF;
 volatile unsigned int UREG0;
 volatile unsigned int UREG1;
 volatile unsigned int UREG2;
 volatile unsigned int UREG3;
} CSP_SYSCON_T;



 typedef volatile struct
 {
    volatile unsigned int EN;
    volatile unsigned int SWTRG;
    volatile unsigned int CH0CON0;
    volatile unsigned int CH0CON1;
    volatile unsigned int CH1CON0;
    volatile unsigned int CH1CON1;
    volatile unsigned int CH2CON0;
    volatile unsigned int CH2CON1;
 volatile unsigned int _RSVD0;
 volatile unsigned int _RSVD1;
 volatile unsigned int _RSVD2;
 volatile unsigned int _RSVD3;
    volatile unsigned int CH3CON;
 volatile unsigned int CH4CON;
 volatile unsigned int CH5CON;
 volatile unsigned int CH6CON;
 volatile unsigned int CH7CON;
 } CSP_ETCB_T, *CSP_ETCB_PTR;



typedef volatile struct
{
   volatile unsigned int TCH_CCR;
   volatile unsigned int TCH_CON0;
   volatile unsigned int TCH_CON1;
   volatile unsigned int TCH_SCCR;
   volatile unsigned int TCH_SENPRD;
   volatile unsigned int TCH_VALBUF;
   volatile unsigned int TCH_SENCNT;
   volatile unsigned int TCH_TCHCNT;
   volatile unsigned int TCH_THR;
   volatile unsigned int Reserved0;
   volatile unsigned int TCH_RISR;
   volatile unsigned int TCH_IER;
   volatile unsigned int TCH_ICR;
   volatile unsigned int TCH_RWSR;
   volatile unsigned int TCH_OVW_THR;
   volatile unsigned int TCH_OVF;
   volatile unsigned int TCH_OVT;
   volatile unsigned int TCH_SYNCR;
   volatile unsigned int TCH_EVTRG;
   volatile unsigned int TCH_EVPS;
   volatile unsigned int TCH_EVSWF;
} CSP_TKEY_T, *CSP_TKEY_PTR;



typedef volatile struct
{
   volatile unsigned int TCH_CHVAL[18];
   volatile unsigned int TCH_SEQCON[18];
} CSP_TKEYBUF_T, *CSP_TKEYBUF_PTR;



 typedef volatile struct
 {
    volatile unsigned int ECR;
    volatile unsigned int DCR;
    volatile unsigned int PMSR;
    volatile unsigned int Reserved0;
    volatile unsigned int CR;
    volatile unsigned int MR;
    volatile unsigned int SHR;
    volatile unsigned int CSR;
    volatile unsigned int SR;
    volatile unsigned int IER;
    volatile unsigned int IDR;
    volatile unsigned int IMR;
    volatile unsigned int SEQ[16];
    volatile unsigned int PRI;
    volatile unsigned int TDL0;
    volatile unsigned int TDL1;
    volatile unsigned int SYNCR;
    volatile unsigned int Reserved1;
    volatile unsigned int Reserved2;
    volatile unsigned int EVTRG;
    volatile unsigned int EVPS;
    volatile unsigned int EVSWF;
    volatile unsigned int ReservedD[27];
    volatile unsigned int DR[16];
    volatile unsigned int CMP0;
    volatile unsigned int CMP1;
 volatile unsigned int DRMASK;
 } CSP_ADC12_T, *CSP_ADC12_PTR;



 typedef volatile struct
 {
    volatile unsigned int CONLR;
    volatile unsigned int CONHR;
    volatile unsigned int WODR;
    volatile unsigned int SODR;
    volatile unsigned int CODR;
    volatile unsigned int ODSR;
    volatile unsigned int PSDR;
    volatile unsigned int FLTEN;
    volatile unsigned int PUDR;
    volatile unsigned int DSCR;
    volatile unsigned int OMCR;
    volatile unsigned int IECR;
 volatile unsigned int IEER;
 volatile unsigned int IEDR;
 } CSP_GPIO_T, *CSP_GPIO_PTR;

 typedef volatile struct
 {
 volatile unsigned int IGRPL;
    volatile unsigned int IGRPH;
 volatile unsigned int IGREX;
    volatile unsigned int IO_CLKEN;
 } CSP_IGRP_T, *CSP_IGRP_PTR;



 typedef volatile struct
 {
    volatile unsigned int DATA;
    volatile unsigned int SR;
    volatile unsigned int CTRL;
    volatile unsigned int ISR;
    volatile unsigned int BRDIV;
    volatile unsigned int ReservedA[20];
 } CSP_UART_T, *CSP_UART_PTR;



typedef struct
{
 volatile unsigned int CR0;
 volatile unsigned int CR1;
 volatile unsigned int DR;
 volatile unsigned int SR;
 volatile unsigned int CPSR;
 volatile unsigned int IMSCR;
 volatile unsigned int RISR;
 volatile unsigned int MISR;
 volatile unsigned int ICR;
} CSP_SSP_T, *CSP_SSP_PTR;



typedef struct
{
 volatile unsigned int CR;
 volatile unsigned int TXCR0;
 volatile unsigned int TXCR1;
 volatile unsigned int TXBUF;
 volatile unsigned int RXCR0;
 volatile unsigned int RXCR1;
 volatile unsigned int RXCR2;
 volatile unsigned int RXBUF;
 volatile unsigned int RISR;
 volatile unsigned int MISR;
 volatile unsigned int IMCR;
 volatile unsigned int ICR;
} CSP_SIO_T, *CSP_SIO_PTR;



 typedef volatile struct
 {
    unsigned int CR;
    unsigned int TADDR;
    unsigned int SADDR;
    unsigned int ReservedD;
    unsigned int DATA_CMD;
    unsigned int SS_SCLH;
    unsigned int SS_SCLL;
    unsigned int FS_SCLH;
    unsigned int FS_SCLL;
    unsigned int ReservedA;
    unsigned int ReservedC;
    unsigned int RX_FLSEL;
    unsigned int TX_FLSEL;
    unsigned int RX_FL;
    unsigned int TX_FL;
    unsigned int ENABLE;
    unsigned int STATUS;
    unsigned int ReservedB;
    unsigned int SDA_TSETUP;
    unsigned int SDA_THOLD;
    unsigned int SPKLEN;

    unsigned int ReservedE;
 unsigned int MISR;
    unsigned int IMSCR;
    unsigned int RISR;
    unsigned int ICR;
    unsigned int ReservedF;
    unsigned int SCL_TOUT;
    unsigned int SDA_TOUT;
    unsigned int TX_ABRT;
    unsigned int GCALL;
    unsigned int NACK;
 } CSP_I2C_T, *CSP_I2C_PTR;



 typedef struct
 {
    volatile unsigned int CADATAH;
    volatile unsigned int CADATAL;
    volatile unsigned int CACON;
    volatile unsigned int INTMASK;
 } CSP_CA_T, *CSP_CA_PTR;



 typedef struct
 {
 volatile unsigned int CEDR;
 volatile unsigned int RSSR;
 volatile unsigned int PSCR;
 volatile unsigned int CR;
 volatile unsigned int SYNCR;
 volatile unsigned int GLDCR;
 volatile unsigned int GLDCFG;
 volatile unsigned int GLDCR2;
 volatile unsigned int Reserved0;
 volatile unsigned int PRDR;
 volatile unsigned int Reserved1;
 volatile unsigned int CMPA;
 volatile unsigned int CMPB;
 volatile unsigned int Reserved2;
 volatile unsigned int Reserved3;
 volatile unsigned int CMPLDR;
 volatile unsigned int CNT;
 volatile unsigned int AQLDR;
 volatile unsigned int AQCRA;
 volatile unsigned int AQCRB;
 volatile unsigned int Reserved4;
 volatile unsigned int Reserved5;
 volatile unsigned int Reserved6;
 volatile unsigned int AQOSF;
 volatile unsigned int AQCSF;
 volatile unsigned int Reserved7;
 volatile unsigned int Reserved8;
 volatile unsigned int Reserved9;
 volatile unsigned int Reserved10;
 volatile unsigned int Reserved11;
 volatile unsigned int Reserved12;
 volatile unsigned int Reserved13;
 volatile unsigned int Reserved14;
 volatile unsigned int Reserved15;
 volatile unsigned int Reserved16;
 volatile unsigned int Reserved17;
 volatile unsigned int Reserved18;
 volatile unsigned int Reserved19;
 volatile unsigned int Reserved20;
 volatile unsigned int Reserved21;
 volatile unsigned int Reserved22;
 volatile unsigned int Reserved23;
 volatile unsigned int Reserved24;
 volatile unsigned int Reserved25;
 volatile unsigned int Reserved26;
 volatile unsigned int Reserved27;
 volatile unsigned int TRGFTCR;
 volatile unsigned int TRGFTWR;
 volatile unsigned int EVTRG;
 volatile unsigned int EVPS;
 volatile unsigned int EVCNTINIT;
 volatile unsigned int EVSWF;
 volatile unsigned int RISR;
 volatile unsigned int MISR;
 volatile unsigned int IMCR;
 volatile unsigned int ICR;
 volatile unsigned int REGLINK;

 }CSP_GPT_T,*CSP_GPT_PTR;



 typedef struct
 {
   volatile unsigned int CEDR;
   volatile unsigned int RSSR;
   volatile unsigned int PSCR;
   volatile unsigned int CR;
   volatile unsigned int SYNCR;
   volatile unsigned int GLDCR;
   volatile unsigned int GLDCFG;
   volatile unsigned int GLDCR2;
   volatile unsigned int HRCFG;
   volatile unsigned int PRDR;
   volatile unsigned int PHSR;
   volatile unsigned int CMPA;
   volatile unsigned int CMPB;
   volatile unsigned int CMPC;
   volatile unsigned int CMPD;
   volatile unsigned int CMPLDR;
   volatile unsigned int CNT;
   volatile unsigned int AQLDR;
   volatile unsigned int AQCRA;
   volatile unsigned int AQCRB;
   volatile unsigned int AQCRC;
   volatile unsigned int AQCRD;
   volatile unsigned int AQTSCR;
   volatile unsigned int AQOSF;
   volatile unsigned int AQCSF;
   volatile unsigned int DBLDR;
   volatile unsigned int DBCR;
   volatile unsigned int DPSCR;
   volatile unsigned int DBDTR;
   volatile unsigned int DBDTF;
   volatile unsigned int CPCR;
   volatile unsigned int EMSRC;
   volatile unsigned int EMSRC2;
   volatile unsigned int EMPOL;
   volatile unsigned int EMECR;
   volatile unsigned int EMOSR;
   volatile unsigned int Reserved;
   volatile unsigned int EMSLSR;
   volatile unsigned int EMSLCLR;
   volatile unsigned int EMHLSR;
   volatile unsigned int EMHLCLR;
   volatile unsigned int EMFRCR;
   volatile unsigned int EMRISR;
   volatile unsigned int EMMISR;
   volatile unsigned int EMIMCR;
   volatile unsigned int EMICR;
   volatile unsigned int TRGFTCR;
   volatile unsigned int TRGFTWR;
   volatile unsigned int EVTRG;
   volatile unsigned int EVPS;
   volatile unsigned int EVCNTINIT;
   volatile unsigned int EVSWF;
   volatile unsigned int RISR;
   volatile unsigned int MISR;
   volatile unsigned int IMCR;
   volatile unsigned int ICR;
   volatile unsigned int REGLINK;
   volatile unsigned int REGLINK2;
   volatile unsigned int REGPROT;
} CSP_EPT_T, *CSP_EPT_PTR;



 typedef volatile struct
 {
   volatile unsigned int CEDR;
   volatile unsigned int RSSR;
   volatile unsigned int PSCR;
   volatile unsigned int CR;
   volatile unsigned int SYNCR;
   volatile unsigned int PRDR;
   volatile unsigned int CMP;
   volatile unsigned int CNT;
   volatile unsigned int TRGFTCR;
   volatile unsigned int TRGFTWR;
   volatile unsigned int EVTRG;
   volatile unsigned int EVPS;
   volatile unsigned int EVSWF;
   volatile unsigned int RISR;
   volatile unsigned int MISR;
   volatile unsigned int IMCR;
   volatile unsigned int ICR;
} CSP_LPT_T, *CSP_LPT_PTR;



 typedef struct
 {
   volatile unsigned int RSSR;
   volatile unsigned int CR;
   volatile unsigned int PSCR;
   volatile unsigned int PRDR;
   volatile unsigned int CMP;
   volatile unsigned int CNT;
   volatile unsigned int EVTRG;
   volatile unsigned int EVPS;
   volatile unsigned int EVCNTINTI;
   volatile unsigned int EVSWF;
   volatile unsigned int RISR;
   volatile unsigned int IMCR;
   volatile unsigned int MISR;
   volatile unsigned int ICR;
} CSP_BT_T, *CSP_BT_PTR;



typedef struct
{
   volatile unsigned int IDR;
   volatile unsigned int CEDR;
   volatile unsigned int SRR;
   volatile unsigned int CR;
   volatile unsigned int SEED;
   volatile unsigned int DATAIN;
   volatile unsigned int DATAOUT;

} CSP_CRC_T, *CSP_CRC_PTR;



 typedef struct
 {
   volatile unsigned int TIMR;
   volatile unsigned int DATR;
   volatile unsigned int CR;
   volatile unsigned int CCR;
   volatile unsigned int ALRAR;
   volatile unsigned int ALRBR;
   volatile unsigned int SSR;
   volatile unsigned int CAL;
   volatile unsigned int RISR;
   volatile unsigned int IMCR;
   volatile unsigned int MISR;
   volatile unsigned int ICR;
   volatile unsigned int KEY;
   volatile unsigned int EVTRG;
   volatile unsigned int EVPS;
   volatile unsigned int EVSWF;
} CSP_RTC_T, *CSP_RTC_PTR;




 typedef struct
 {
  volatile unsigned int CR;
  volatile unsigned int CFGR;
  volatile unsigned int RISR;
  volatile unsigned int MISR;
  volatile unsigned int IMCR;
  volatile unsigned int ICR;
 }CSP_WWDT_T,*CSP_WWDT_PTR;



 typedef struct
 {
  volatile S32_T DIVIDENT;
  volatile S32_T DIVISOR;
  volatile S32_T QUOTIENT;
  volatile S32_T REMAIN;
  volatile unsigned int CR;
 }CSP_HWD_T,*CSP_HWD_PTR;
# 691 "include/apt32f102.h"
extern CSP_CK801_T *CK801 ;

extern CSP_IFC_T *IFC ;
extern CSP_SYSCON_T *SYSCON ;
extern CSP_ETCB_T *ETCB ;

extern CSP_TKEY_T *TKEY ;
extern CSP_TKEYBUF_T *TKEYBUF ;
extern CSP_ADC12_T *ADC0 ;

extern CSP_GPIO_T *GPIOA0 ;
extern CSP_GPIO_T *GPIOB0 ;
extern CSP_IGRP_T *GPIOGRP ;

extern CSP_UART_T *UART0 ;
extern CSP_UART_T *UART1 ;
extern CSP_UART_T *UART2 ;
extern CSP_SSP_T *SPI0 ;
extern CSP_SIO_T *SIO0 ;
extern CSP_I2C_T *I2C0 ;
extern CSP_CA_T *CA0 ;

extern CSP_GPT_T *GPT0 ;

extern CSP_EPT_T *EPT0 ;

extern CSP_LPT_T *LPT ;
extern CSP_HWD_T *HWD ;
extern CSP_WWDT_T *WWDT ;
extern CSP_BT_T *BT0 ;
extern CSP_BT_T *BT1 ;

extern CSP_CRC_T *CRC ;
extern CSP_RTC_T *RTC ;


void MisalignedHandler(void) __attribute__((isr));
void IllegalInstrHandler(void) __attribute__((isr));
void AccessErrHandler(void) __attribute__((isr));
void BreakPointHandler(void) __attribute__((isr));
void UnrecExecpHandler(void) __attribute__((isr));
void Trap0Handler(void) __attribute__((isr));
void Trap1Handler(void) __attribute__((isr));
void Trap2Handler(void) __attribute__((isr));
void Trap3Handler(void) __attribute__((isr));
void PendTrapHandler(void) __attribute__((isr));

void CORETHandler(void) __attribute__((isr));
void SYSCONIntHandler(void) __attribute__((isr));
void IFCIntHandler(void) __attribute__((isr));
void ADCIntHandler(void) __attribute__((isr));
void EPT0IntHandler(void) __attribute__((isr));
void WWDTHandler(void) __attribute__((isr));
void EXI0IntHandler(void) __attribute__((isr));
void EXI1IntHandler(void) __attribute__((isr));
void EXI2to3IntHandler(void) __attribute__((isr));
void EXI4to9IntHandler(void) __attribute__((isr));
void EXI10to15IntHandler(void) __attribute__((isr));
void UART0IntHandler(void) __attribute__((isr));
void UART1IntHandler(void) __attribute__((isr));
void UART2IntHandler(void) __attribute__((isr));
void I2CIntHandler(void) __attribute__((isr));
void GPT0IntHandler(void) __attribute__((isr));
void LEDIntHandler(void) __attribute__((isr));
void TKEYIntHandler(void) __attribute__((isr));
void SPI0IntHandler(void) __attribute__((isr));
void SIO0IntHandler(void) __attribute__((isr));
void CNTAIntHandler(void) __attribute__((isr));
void RTCIntHandler(void) __attribute__((isr));
void LPTIntHandler(void) __attribute__((isr));
void BT0IntHandler(void) __attribute__((isr));
void BT1IntHandler(void) __attribute__((isr));

extern int __divsi3 (int a, int b);
extern unsigned int __udivsi3 (unsigned int a, unsigned int b);
extern int __modsi3 (int a, int b);
extern unsigned int __umodsi3 (unsigned int a, unsigned int b);
extern void delay_nms(unsigned int t);
extern void delay_nus(unsigned int t);
# 24 "include/apt32f102_ifc.h" 2
# 68 "include/apt32f102_ifc.h"
typedef enum
{
 PROM_PageAdd0 = ((CSP_REGISTER_T)0x00000000),
 PROM_PageAdd1 = ((CSP_REGISTER_T)0x00000100),
 PROM_PageAdd2 = ((CSP_REGISTER_T)0x00000200),
 PROM_PageAdd3 = ((CSP_REGISTER_T)0x00000300),
 PROM_PageAdd4 = ((CSP_REGISTER_T)0x00000400),
 PROM_PageAdd5 = ((CSP_REGISTER_T)0x00000500),
 PROM_PageAdd6 = ((CSP_REGISTER_T)0x00000600),
 PROM_PageAdd7 = ((CSP_REGISTER_T)0x00000700),
 PROM_PageAdd8 = ((CSP_REGISTER_T)0x00000800),
 PROM_PageAdd9 = ((CSP_REGISTER_T)0x00000900),

 PROM_PageAdd10 = ((CSP_REGISTER_T)0x00000A00),
 PROM_PageAdd11 = ((CSP_REGISTER_T)0x00000B00),
 PROM_PageAdd12 = ((CSP_REGISTER_T)0x00000C00),
 PROM_PageAdd13 = ((CSP_REGISTER_T)0x00000D00),
 PROM_PageAdd14 = ((CSP_REGISTER_T)0x00000E00),
 PROM_PageAdd15 = ((CSP_REGISTER_T)0x00000F00),
 PROM_PageAdd16 = ((CSP_REGISTER_T)0x00001000),
 PROM_PageAdd17 = ((CSP_REGISTER_T)0x00001100),
 PROM_PageAdd18 = ((CSP_REGISTER_T)0x00001200),
 PROM_PageAdd19 = ((CSP_REGISTER_T)0x00001300),

 PROM_PageAdd20 = ((CSP_REGISTER_T)0x00001400),
 PROM_PageAdd21 = ((CSP_REGISTER_T)0x00001500),
 PROM_PageAdd22 = ((CSP_REGISTER_T)0x00001600),
 PROM_PageAdd23 = ((CSP_REGISTER_T)0x00001700),
 PROM_PageAdd24 = ((CSP_REGISTER_T)0x00001800),
 PROM_PageAdd25 = ((CSP_REGISTER_T)0x00001900),
 PROM_PageAdd26 = ((CSP_REGISTER_T)0x00001A00),
 PROM_PageAdd27 = ((CSP_REGISTER_T)0x00001B00),
 PROM_PageAdd28 = ((CSP_REGISTER_T)0x00001C00),
 PROM_PageAdd29 = ((CSP_REGISTER_T)0x00001D00),

 PROM_PageAdd30 = ((CSP_REGISTER_T)0x00001E00),
 PROM_PageAdd31 = ((CSP_REGISTER_T)0x00001F00),
 PROM_PageAdd32 = ((CSP_REGISTER_T)0x00002000),
 PROM_PageAdd33 = ((CSP_REGISTER_T)0x00002100),
 PROM_PageAdd34 = ((CSP_REGISTER_T)0x00002200),
 PROM_PageAdd35 = ((CSP_REGISTER_T)0x00002300),
 PROM_PageAdd36 = ((CSP_REGISTER_T)0x00002400),
 PROM_PageAdd37 = ((CSP_REGISTER_T)0x00002500),
 PROM_PageAdd38 = ((CSP_REGISTER_T)0x00002600),
 PROM_PageAdd39 = ((CSP_REGISTER_T)0x00002700),

 PROM_PageAdd40 = ((CSP_REGISTER_T)0x00002800),
 PROM_PageAdd41 = ((CSP_REGISTER_T)0x00002900),
 PROM_PageAdd42 = ((CSP_REGISTER_T)0x00002A00),
 PROM_PageAdd43 = ((CSP_REGISTER_T)0x00002B00),
 PROM_PageAdd44 = ((CSP_REGISTER_T)0x00002C00),
 PROM_PageAdd45 = ((CSP_REGISTER_T)0x00002D00),
 PROM_PageAdd46 = ((CSP_REGISTER_T)0x00002E00),
 PROM_PageAdd47 = ((CSP_REGISTER_T)0x00002F00),
 PROM_PageAdd48 = ((CSP_REGISTER_T)0x00003000),
 PROM_PageAdd49 = ((CSP_REGISTER_T)0x00003100),

 PROM_PageAdd50 = ((CSP_REGISTER_T)0x00003200),
 PROM_PageAdd51 = ((CSP_REGISTER_T)0x00003300),
 PROM_PageAdd52 = ((CSP_REGISTER_T)0x00003400),
 PROM_PageAdd53 = ((CSP_REGISTER_T)0x00003500),
 PROM_PageAdd54 = ((CSP_REGISTER_T)0x00003600),
 PROM_PageAdd55 = ((CSP_REGISTER_T)0x00003700),
 PROM_PageAdd56 = ((CSP_REGISTER_T)0x00003800),
 PROM_PageAdd57 = ((CSP_REGISTER_T)0x00003900),
 PROM_PageAdd58 = ((CSP_REGISTER_T)0x00003A00),
 PROM_PageAdd59 = ((CSP_REGISTER_T)0x00003B00),

 PROM_PageAdd60 = ((CSP_REGISTER_T)0x00003C00),
 PROM_PageAdd61 = ((CSP_REGISTER_T)0x00003D00),
 PROM_PageAdd62 = ((CSP_REGISTER_T)0x00003E00),
 PROM_PageAdd63 = ((CSP_REGISTER_T)0x00003F00),
 PROM_PageAdd64 = ((CSP_REGISTER_T)0x00004000),
 PROM_PageAdd65 = ((CSP_REGISTER_T)0x00004100),
 PROM_PageAdd66 = ((CSP_REGISTER_T)0x00004200),
 PROM_PageAdd67 = ((CSP_REGISTER_T)0x00004300),
 PROM_PageAdd68 = ((CSP_REGISTER_T)0x00004400),
 PROM_PageAdd69 = ((CSP_REGISTER_T)0x00004500),

 PROM_PageAdd70 = ((CSP_REGISTER_T)0x00004600),
 PROM_PageAdd71 = ((CSP_REGISTER_T)0x00004700),
 PROM_PageAdd72 = ((CSP_REGISTER_T)0x00004800),
 PROM_PageAdd73 = ((CSP_REGISTER_T)0x00004900),
 PROM_PageAdd74 = ((CSP_REGISTER_T)0x00004A00),
 PROM_PageAdd75 = ((CSP_REGISTER_T)0x00004B00),
 PROM_PageAdd76 = ((CSP_REGISTER_T)0x00004C00),
 PROM_PageAdd77 = ((CSP_REGISTER_T)0x00004D00),
 PROM_PageAdd78 = ((CSP_REGISTER_T)0x00004E00),
 PROM_PageAdd79 = ((CSP_REGISTER_T)0x00004F00),

 PROM_PageAdd80 = ((CSP_REGISTER_T)0x00005000),
 PROM_PageAdd81 = ((CSP_REGISTER_T)0x00005100),
 PROM_PageAdd82 = ((CSP_REGISTER_T)0x00005200),
 PROM_PageAdd83 = ((CSP_REGISTER_T)0x00005300),
 PROM_PageAdd84 = ((CSP_REGISTER_T)0x00005400),
 PROM_PageAdd85 = ((CSP_REGISTER_T)0x00005500),
 PROM_PageAdd86 = ((CSP_REGISTER_T)0x00005600),
 PROM_PageAdd87 = ((CSP_REGISTER_T)0x00005700),
 PROM_PageAdd88 = ((CSP_REGISTER_T)0x00005800),
 PROM_PageAdd89 = ((CSP_REGISTER_T)0x00005900),

 PROM_PageAdd90 = ((CSP_REGISTER_T)0x00005A00),
 PROM_PageAdd91 = ((CSP_REGISTER_T)0x00005B00),
 PROM_PageAdd92 = ((CSP_REGISTER_T)0x00005C00),
 PROM_PageAdd93 = ((CSP_REGISTER_T)0x00005D00),
 PROM_PageAdd94 = ((CSP_REGISTER_T)0x00005E00),
 PROM_PageAdd95 = ((CSP_REGISTER_T)0x00005F00),
 PROM_PageAdd96 = ((CSP_REGISTER_T)0x00006000),
 PROM_PageAdd97 = ((CSP_REGISTER_T)0x00006100),
 PROM_PageAdd98 = ((CSP_REGISTER_T)0x00006200),
 PROM_PageAdd99 = ((CSP_REGISTER_T)0x00006300),

 PROM_PageAdd100 = ((CSP_REGISTER_T)0x00006400),
 PROM_PageAdd101 = ((CSP_REGISTER_T)0x00006500),
 PROM_PageAdd102 = ((CSP_REGISTER_T)0x00006600),
 PROM_PageAdd103 = ((CSP_REGISTER_T)0x00006700),
 PROM_PageAdd104 = ((CSP_REGISTER_T)0x00006800),
 PROM_PageAdd105 = ((CSP_REGISTER_T)0x00006900),
 PROM_PageAdd106 = ((CSP_REGISTER_T)0x00006A00),
 PROM_PageAdd107 = ((CSP_REGISTER_T)0x00006B00),
 PROM_PageAdd108 = ((CSP_REGISTER_T)0x00006C00),
 PROM_PageAdd109 = ((CSP_REGISTER_T)0x00006D00),

 PROM_PageAdd110 = ((CSP_REGISTER_T)0x00006E00),
 PROM_PageAdd111 = ((CSP_REGISTER_T)0x00006F00),
 PROM_PageAdd112 = ((CSP_REGISTER_T)0x00007000),
 PROM_PageAdd113 = ((CSP_REGISTER_T)0x00007100),
 PROM_PageAdd114 = ((CSP_REGISTER_T)0x00007200),
 PROM_PageAdd115 = ((CSP_REGISTER_T)0x00007300),
 PROM_PageAdd116 = ((CSP_REGISTER_T)0x00007400),
 PROM_PageAdd117 = ((CSP_REGISTER_T)0x00007500),
 PROM_PageAdd118 = ((CSP_REGISTER_T)0x00007600),
 PROM_PageAdd119 = ((CSP_REGISTER_T)0x00007700),

 PROM_PageAdd120 = ((CSP_REGISTER_T)0x00007800),
 PROM_PageAdd121 = ((CSP_REGISTER_T)0x00007900),
 PROM_PageAdd122 = ((CSP_REGISTER_T)0x00007A00),
 PROM_PageAdd123 = ((CSP_REGISTER_T)0x00007B00),
 PROM_PageAdd124 = ((CSP_REGISTER_T)0x00007C00),
 PROM_PageAdd125 = ((CSP_REGISTER_T)0x00007D00),
 PROM_PageAdd126 = ((CSP_REGISTER_T)0x00007E00),
 PROM_PageAdd127 = ((CSP_REGISTER_T)0x00007F00),
 PROM_PageAdd128 = ((CSP_REGISTER_T)0x00008000),
 PROM_PageAdd129 = ((CSP_REGISTER_T)0x00008100),

 PROM_PageAdd130 = ((CSP_REGISTER_T)0x00008200),
 PROM_PageAdd131 = ((CSP_REGISTER_T)0x00008300),
 PROM_PageAdd132 = ((CSP_REGISTER_T)0x00008400),
 PROM_PageAdd133 = ((CSP_REGISTER_T)0x00008500),
 PROM_PageAdd134 = ((CSP_REGISTER_T)0x00008600),
 PROM_PageAdd135 = ((CSP_REGISTER_T)0x00008700),
 PROM_PageAdd136 = ((CSP_REGISTER_T)0x00008800),
 PROM_PageAdd137 = ((CSP_REGISTER_T)0x00008900),
 PROM_PageAdd138 = ((CSP_REGISTER_T)0x00008A00),
 PROM_PageAdd139 = ((CSP_REGISTER_T)0x00008B00),

 PROM_PageAdd140 = ((CSP_REGISTER_T)0x00008C00),
 PROM_PageAdd141 = ((CSP_REGISTER_T)0x00008D00),
 PROM_PageAdd142 = ((CSP_REGISTER_T)0x00008E00),
 PROM_PageAdd143 = ((CSP_REGISTER_T)0x00008F00),
 PROM_PageAdd144 = ((CSP_REGISTER_T)0x00009000),
 PROM_PageAdd145 = ((CSP_REGISTER_T)0x00009100),
 PROM_PageAdd146 = ((CSP_REGISTER_T)0x00009200),
 PROM_PageAdd147 = ((CSP_REGISTER_T)0x00009300),
 PROM_PageAdd148 = ((CSP_REGISTER_T)0x00009400),
 PROM_PageAdd149 = ((CSP_REGISTER_T)0x00009500),

 PROM_PageAdd150 = ((CSP_REGISTER_T)0x00009600),
 PROM_PageAdd151 = ((CSP_REGISTER_T)0x00009700),
 PROM_PageAdd152 = ((CSP_REGISTER_T)0x00009800),
 PROM_PageAdd153 = ((CSP_REGISTER_T)0x00009900),
 PROM_PageAdd154 = ((CSP_REGISTER_T)0x00009A00),
 PROM_PageAdd155 = ((CSP_REGISTER_T)0x00009B00),
 PROM_PageAdd156 = ((CSP_REGISTER_T)0x00009C00),
 PROM_PageAdd157 = ((CSP_REGISTER_T)0x00009D00),
 PROM_PageAdd158 = ((CSP_REGISTER_T)0x00009E00),
 PROM_PageAdd159 = ((CSP_REGISTER_T)0x00009F00),

 PROM_PageAdd160 = ((CSP_REGISTER_T)0x0000A000),
 PROM_PageAdd161 = ((CSP_REGISTER_T)0x0000A100),
 PROM_PageAdd162 = ((CSP_REGISTER_T)0x0000A200),
 PROM_PageAdd163 = ((CSP_REGISTER_T)0x0000A300),
 PROM_PageAdd164 = ((CSP_REGISTER_T)0x0000A400),
 PROM_PageAdd165 = ((CSP_REGISTER_T)0x0000A500),
 PROM_PageAdd166 = ((CSP_REGISTER_T)0x0000A600),
 PROM_PageAdd167 = ((CSP_REGISTER_T)0x0000A700),
 PROM_PageAdd168 = ((CSP_REGISTER_T)0x0000A800),
 PROM_PageAdd169 = ((CSP_REGISTER_T)0x0000A900),

 PROM_PageAdd170 = ((CSP_REGISTER_T)0x0000AA00),
 PROM_PageAdd171 = ((CSP_REGISTER_T)0x0000AB00),
 PROM_PageAdd172 = ((CSP_REGISTER_T)0x0000AC00),
 PROM_PageAdd173 = ((CSP_REGISTER_T)0x0000AD00),
 PROM_PageAdd174 = ((CSP_REGISTER_T)0x0000AE00),
 PROM_PageAdd175 = ((CSP_REGISTER_T)0x0000AF00),
 PROM_PageAdd176 = ((CSP_REGISTER_T)0x0000B000),
 PROM_PageAdd177 = ((CSP_REGISTER_T)0x0000B100),
 PROM_PageAdd178 = ((CSP_REGISTER_T)0x0000B200),
 PROM_PageAdd179 = ((CSP_REGISTER_T)0x0000B300),

 PROM_PageAdd180 = ((CSP_REGISTER_T)0x0000B400),
 PROM_PageAdd181 = ((CSP_REGISTER_T)0x0000B500),
 PROM_PageAdd182 = ((CSP_REGISTER_T)0x0000B600),
 PROM_PageAdd183 = ((CSP_REGISTER_T)0x0000B700),
 PROM_PageAdd184 = ((CSP_REGISTER_T)0x0000B800),
 PROM_PageAdd185 = ((CSP_REGISTER_T)0x0000B900),
 PROM_PageAdd186 = ((CSP_REGISTER_T)0x0000BA00),
 PROM_PageAdd187 = ((CSP_REGISTER_T)0x0000BB00),
 PROM_PageAdd188 = ((CSP_REGISTER_T)0x0000BC00),
 PROM_PageAdd189 = ((CSP_REGISTER_T)0x0000BD00),

 PROM_PageAdd190 = ((CSP_REGISTER_T)0x0000BE00),
 PROM_PageAdd191 = ((CSP_REGISTER_T)0x0000BF00),
 PROM_PageAdd192 = ((CSP_REGISTER_T)0x0000C000),
 PROM_PageAdd193 = ((CSP_REGISTER_T)0x0000C100),
 PROM_PageAdd194 = ((CSP_REGISTER_T)0x0000C200),
 PROM_PageAdd195 = ((CSP_REGISTER_T)0x0000C300),
 PROM_PageAdd196 = ((CSP_REGISTER_T)0x0000C400),
 PROM_PageAdd197 = ((CSP_REGISTER_T)0x0000C500),
 PROM_PageAdd198 = ((CSP_REGISTER_T)0x0000C600),
 PROM_PageAdd199 = ((CSP_REGISTER_T)0x0000C700),

 PROM_PageAdd200 = ((CSP_REGISTER_T)0x0000C800),
 PROM_PageAdd201 = ((CSP_REGISTER_T)0x0000C900),
 PROM_PageAdd202 = ((CSP_REGISTER_T)0x0000CA00),
 PROM_PageAdd203 = ((CSP_REGISTER_T)0x0000CB00),
 PROM_PageAdd204 = ((CSP_REGISTER_T)0x0000CC00),
 PROM_PageAdd205 = ((CSP_REGISTER_T)0x0000CD00),
 PROM_PageAdd206 = ((CSP_REGISTER_T)0x0000CE00),
 PROM_PageAdd207 = ((CSP_REGISTER_T)0x0000CF00),
 PROM_PageAdd208 = ((CSP_REGISTER_T)0x0000D000),
 PROM_PageAdd209 = ((CSP_REGISTER_T)0x0000D100),

 PROM_PageAdd210 = ((CSP_REGISTER_T)0x0000D200),
 PROM_PageAdd211 = ((CSP_REGISTER_T)0x0000D300),
 PROM_PageAdd212 = ((CSP_REGISTER_T)0x0000D400),
 PROM_PageAdd213 = ((CSP_REGISTER_T)0x0000D500),
 PROM_PageAdd214 = ((CSP_REGISTER_T)0x0000D600),
 PROM_PageAdd215 = ((CSP_REGISTER_T)0x0000D700),
 PROM_PageAdd216 = ((CSP_REGISTER_T)0x0000D800),
 PROM_PageAdd217 = ((CSP_REGISTER_T)0x0000D900),
 PROM_PageAdd218 = ((CSP_REGISTER_T)0x0000DA00),
 PROM_PageAdd219 = ((CSP_REGISTER_T)0x0000DB00),

 PROM_PageAdd220 = ((CSP_REGISTER_T)0x0000DC00),
 PROM_PageAdd221 = ((CSP_REGISTER_T)0x0000DD00),
 PROM_PageAdd222 = ((CSP_REGISTER_T)0x0000DE00),
 PROM_PageAdd223 = ((CSP_REGISTER_T)0x0000DF00),
 PROM_PageAdd224 = ((CSP_REGISTER_T)0x0000E000),
 PROM_PageAdd225 = ((CSP_REGISTER_T)0x0000E100),
 PROM_PageAdd226 = ((CSP_REGISTER_T)0x0000E200),
 PROM_PageAdd227 = ((CSP_REGISTER_T)0x0000E300),
 PROM_PageAdd228 = ((CSP_REGISTER_T)0x0000E400),
 PROM_PageAdd229 = ((CSP_REGISTER_T)0x0000E500),

 PROM_PageAdd230 = ((CSP_REGISTER_T)0x0000E600),
 PROM_PageAdd231 = ((CSP_REGISTER_T)0x0000E700),
 PROM_PageAdd232 = ((CSP_REGISTER_T)0x0000E800),
 PROM_PageAdd233 = ((CSP_REGISTER_T)0x0000E900),
 PROM_PageAdd234 = ((CSP_REGISTER_T)0x0000EA00),
 PROM_PageAdd235 = ((CSP_REGISTER_T)0x0000EB00),
 PROM_PageAdd236 = ((CSP_REGISTER_T)0x0000EC00),
 PROM_PageAdd237 = ((CSP_REGISTER_T)0x0000ED00),
 PROM_PageAdd238 = ((CSP_REGISTER_T)0x0000EE00),
 PROM_PageAdd239 = ((CSP_REGISTER_T)0x0000EF00),

 PROM_PageAdd240 = ((CSP_REGISTER_T)0x0000F000),
 PROM_PageAdd241 = ((CSP_REGISTER_T)0x0000F100),
 PROM_PageAdd242 = ((CSP_REGISTER_T)0x0000F200),
 PROM_PageAdd243 = ((CSP_REGISTER_T)0x0000F300),
 PROM_PageAdd244 = ((CSP_REGISTER_T)0x0000F400),
 PROM_PageAdd245 = ((CSP_REGISTER_T)0x0000F50),
 PROM_PageAdd246 = ((CSP_REGISTER_T)0x0000F600),
 PROM_PageAdd247 = ((CSP_REGISTER_T)0x0000F700),
 PROM_PageAdd248 = ((CSP_REGISTER_T)0x0000F800),
 PROM_PageAdd249 = ((CSP_REGISTER_T)0x0000F900),

 PROM_PageAdd250 = ((CSP_REGISTER_T)0x0000FA00),
 PROM_PageAdd251 = ((CSP_REGISTER_T)0x0000FB00),
 PROM_PageAdd252 = ((CSP_REGISTER_T)0x0000FC00),
 PROM_PageAdd253 = ((CSP_REGISTER_T)0x0000FD00),
 PROM_PageAdd254 = ((CSP_REGISTER_T)0x0000FE00),
 PROM_PageAdd255 = ((CSP_REGISTER_T)0x0000FF00),

 DROM_PageAdd0 = ((CSP_REGISTER_T)0x10000000),
 DROM_PageAdd1 = ((CSP_REGISTER_T)0x10000040),
 DROM_PageAdd2 = ((CSP_REGISTER_T)0x10000080),
 DROM_PageAdd3 = ((CSP_REGISTER_T)0x100000C0),
 DROM_PageAdd4 = ((CSP_REGISTER_T)0x10000100),
 DROM_PageAdd5 = ((CSP_REGISTER_T)0x10000140),
 DROM_PageAdd6 = ((CSP_REGISTER_T)0x10000180),
 DROM_PageAdd7 = ((CSP_REGISTER_T)0x100001C0),
 DROM_PageAdd8 = ((CSP_REGISTER_T)0x10000200),
 DROM_PageAdd9 = ((CSP_REGISTER_T)0x10000240),

 DROM_PageAdd10 = ((CSP_REGISTER_T)0x10000280),
 DROM_PageAdd11 = ((CSP_REGISTER_T)0x100002C0),
 DROM_PageAdd12 = ((CSP_REGISTER_T)0x10000300),
 DROM_PageAdd13 = ((CSP_REGISTER_T)0x10000340),
 DROM_PageAdd14 = ((CSP_REGISTER_T)0x10000380),
 DROM_PageAdd15 = ((CSP_REGISTER_T)0x100003C0),
 DROM_PageAdd16 = ((CSP_REGISTER_T)0x10000400),
 DROM_PageAdd17 = ((CSP_REGISTER_T)0x10000440),
 DROM_PageAdd18 = ((CSP_REGISTER_T)0x10000480),
 DROM_PageAdd19 = ((CSP_REGISTER_T)0x100004C0),

 DROM_PageAdd20 = ((CSP_REGISTER_T)0x10000500),
 DROM_PageAdd21 = ((CSP_REGISTER_T)0x10000540),
 DROM_PageAdd22 = ((CSP_REGISTER_T)0x10000580),
 DROM_PageAdd23 = ((CSP_REGISTER_T)0x100005C0),
 DROM_PageAdd24 = ((CSP_REGISTER_T)0x10000600),
 DROM_PageAdd25 = ((CSP_REGISTER_T)0x10000640),
 DROM_PageAdd26 = ((CSP_REGISTER_T)0x10000680),
 DROM_PageAdd27 = ((CSP_REGISTER_T)0x100006C0),
 DROM_PageAdd28 = ((CSP_REGISTER_T)0x10000700),
 DROM_PageAdd29 = ((CSP_REGISTER_T)0x10000740),

 DROM_PageAdd30 = ((CSP_REGISTER_T)0x10000780),
 DROM_PageAdd31 = ((CSP_REGISTER_T)0x100007C0)
}IFC_ROMSELETED_TypeDef;




typedef enum
{
 ERS_END_INT = (0x01ul),
 RGM_END_INT = ((0x01ul)<<1),
 PEP_END_INT = ((0x01ul)<<2),
 PROT_ERR_INT = ((0x01ul)<<12),
 UDEF_ERR_INT = ((0x01ul)<<13),
 ADDR_ERR_INT = ((0x01ul)<<14),
 OVW_ERR_INT = ((0x01ul)<<15)
}IFC_INT_TypeDef;


extern void ChipErase(void);
extern void PageErase(IFC_ROMSELETED_TypeDef XROM_PageAd);
extern void IFC_interrupt_CMD(FunctionalStatus NewState ,IFC_INT_TypeDef IFC_INT_x);
extern void IFC_Int_Enable(void);
extern void IFC_Int_Disable(void);
extern void Page_ProgramData(unsigned int FlashAdd,unsigned int DataSize,volatile unsigned char *BufArry);
extern void Page_ProgramData_int(unsigned int FlashAdd,unsigned int DataSize,volatile unsigned char *BufArry);
extern void ReadDataArry(unsigned int RdStartAdd,unsigned int DataLength,volatile unsigned char *DataArryPoint);
extern void ReadDataArry_U8(unsigned int RdStartAdd,unsigned int DataLength,volatile unsigned char *DataArryPoint);
extern volatile unsigned int R_INT_FlashAdd;
extern volatile unsigned char f_Drom_write_complete;
extern volatile unsigned char f_Drom_writing;
extern volatile unsigned char ifc_step;

extern void Page_ProgramData2(unsigned int FlashAdd,unsigned int DataSize,volatile unsigned int *BufArry);
extern void Page_ProgramData3(unsigned int FlashAdd,unsigned int DataSize,volatile unsigned int Data);
extern void ReadDataArry2(unsigned int RdStartAdd,unsigned int DataLength,volatile unsigned int *DataArryPoint);
# 20 "FWlib/apt32f102_ifc.c" 2
volatile unsigned int R_INT_FlashAdd;
volatile unsigned char f_Drom_write_complete=0;
volatile unsigned char f_Drom_writing=0;
volatile unsigned char ifc_step;

extern void delay_nms(unsigned int t);






void ChipErase(void)
{
 (IFC->KR = ((0x5A5A5A5Aul)));
 (IFC->CMR=((0x04ul)|((0x1ul)<<8)));
 (IFC->CR=((0x01ul)));
 while(IFC->CR!=0x0);
}







void PageErase(IFC_ROMSELETED_TypeDef XROM_PageAdd)
{
 (IFC->KR = ((0x5A5A5A5Aul)));
 (IFC->CMR=((0x02ul)|((0x0ul)<<8)));
 IFC->FM_ADDR=XROM_PageAdd;
 (IFC->CR=((0x01ul)));
 while(IFC->CR!=0x0);
}
# 62 "FWlib/apt32f102_ifc.c"
void Page_ProgramData_int(unsigned int FlashAdd,unsigned int DataSize,volatile unsigned char *BufArry)
{
 int i,DataBuffer;
 if(!f_Drom_writing)
 {
  f_Drom_writing=1;
  R_INT_FlashAdd=FlashAdd;
  ifc_step=0;

  (IFC->KR = ((0x5A5A5A5Aul)));
  IFC->CMR=0x07;
  IFC->FM_ADDR=FlashAdd;
  IFC->CR=0X01;
  while(IFC->CR!=0x0);

  for(i=0;i<((DataSize+3)/4);i++)
  {
   DataBuffer=*BufArry+(*(BufArry+1)<<8)+(*(BufArry+2)<<16)+(*(BufArry+3)<<24);
   *(volatile unsigned int *)(FlashAdd+4*i)=DataBuffer;
   BufArry +=4;
  }

  (IFC->KR = ((0x5A5A5A5Aul)));
  IFC->CMR=0x06;
  IFC->FM_ADDR=FlashAdd;
  IFC->CR=0X01;
  while(IFC->CR!=0x0);

  (IFC->KR = ((0x5A5A5A5Aul)));
  IFC->CMR=0x01;
  IFC->FM_ADDR=FlashAdd;
  IFC->CR=0X01;
 }
}

void Page_ProgramData(unsigned int FlashAdd,unsigned int DataSize,volatile unsigned char *BufArry)
{
 int i,DataBuffer;


 (IFC->KR = ((0x5A5A5A5Aul)));
 IFC->CMR=0x07;
 IFC->FM_ADDR=FlashAdd;
 IFC->CR=0X01;
 while(IFC->CR!=0x0);


 for(i=0;i<((DataSize+3)/4);i++)
 {
  DataBuffer=*BufArry+(*(BufArry+1)<<8)+(*(BufArry+2)<<16)+(*(BufArry+3)<<24);
  *(volatile unsigned int *)(FlashAdd+4*i)=DataBuffer;
  BufArry +=4;
 }


 (IFC->KR = ((0x5A5A5A5Aul)));
 IFC->CMR=0x06;
 IFC->FM_ADDR=FlashAdd;
 IFC->CR=0X01;
 while(IFC->CR!=0x0);

 (IFC->KR = ((0x5A5A5A5Aul)));
 IFC->CMR=0x01;
 IFC->FM_ADDR=FlashAdd;
 IFC->CR=0X01;
 while(IFC->RISR!=PEP_END_INT);

 (IFC->KR = ((0x5A5A5A5Aul)));
 IFC->CMR=0x02;
 IFC->FM_ADDR=FlashAdd;
 IFC->CR=0X01;
 while(IFC->RISR!=ERS_END_INT);

 (IFC->KR = ((0x5A5A5A5Aul)));
 IFC->CMR=0x01;
 IFC->FM_ADDR=FlashAdd;
 IFC->CR=0X01;
 while(IFC->RISR!=RGM_END_INT);
}
void Page_ProgramData2(unsigned int FlashAdd,unsigned int DataSize,volatile unsigned int *BufArry)
{
 int i,DataBuffer;


 (IFC->KR = ((0x5A5A5A5Aul)));
 IFC->CMR=0x07;
 IFC->FM_ADDR=FlashAdd;
 IFC->CR=0X01;
 while(IFC->CR!=0x0);


 for(i=0;i<DataSize;i++)
 {
  DataBuffer = *BufArry;
  *(volatile unsigned int *)(FlashAdd+4*i) = DataBuffer;
  BufArry += 1;
 }


 (IFC->KR = ((0x5A5A5A5Aul)));
 IFC->CMR=0x06;
 IFC->FM_ADDR=FlashAdd;
 IFC->CR=0X01;
 while(IFC->CR!=0x0);

 (IFC->KR = ((0x5A5A5A5Aul)));
 IFC->CMR=0x01;
 IFC->FM_ADDR=FlashAdd;
 IFC->CR=0X01;
 while(IFC->RISR!=PEP_END_INT);

 (IFC->KR = ((0x5A5A5A5Aul)));
 IFC->CMR=0x02;
 IFC->FM_ADDR=FlashAdd;
 IFC->CR=0X01;
 while(IFC->RISR!=ERS_END_INT);

 (IFC->KR = ((0x5A5A5A5Aul)));
 IFC->CMR=0x01;
 IFC->FM_ADDR=FlashAdd;
 IFC->CR=0X01;
 while(IFC->RISR!=RGM_END_INT);
}


void Page_ProgramData3(unsigned int FlashAdd,unsigned int DataSize,volatile unsigned int Data)
{
 int i;


 (IFC->KR = ((0x5A5A5A5Aul)));
 IFC->CMR=0x07;
 IFC->FM_ADDR=FlashAdd;
 IFC->CR=0X01;
 while(IFC->CR!=0x0);


 for(i=0;i<DataSize;i++)
 {
  *(volatile unsigned int *)(FlashAdd+4*i) = Data;
 }


 (IFC->KR = ((0x5A5A5A5Aul)));
 IFC->CMR=0x06;
 IFC->FM_ADDR=FlashAdd;
 IFC->CR=0X01;
 while(IFC->CR!=0x0);

 (IFC->KR = ((0x5A5A5A5Aul)));
 IFC->CMR=0x01;
 IFC->FM_ADDR=FlashAdd;
 IFC->CR=0X01;
 while(IFC->RISR!=PEP_END_INT);

 (IFC->KR = ((0x5A5A5A5Aul)));
 IFC->CMR=0x02;
 IFC->FM_ADDR=FlashAdd;
 IFC->CR=0X01;
 while(IFC->RISR!=ERS_END_INT);

 (IFC->KR = ((0x5A5A5A5Aul)));
 IFC->CMR=0x01;
 IFC->FM_ADDR=FlashAdd;
 IFC->CR=0X01;
 while(IFC->RISR!=RGM_END_INT);
}
# 237 "FWlib/apt32f102_ifc.c"
void ReadDataArry(unsigned int RdStartAdd,unsigned int DataLength,volatile unsigned char *DataArryPoint)
{
 unsigned int i,Buffer;

 for(i=0;i<((DataLength+3)/4);i++)
 {
  Buffer=*(volatile unsigned int *)RdStartAdd;
  *DataArryPoint=Buffer;
  *(DataArryPoint+1)=Buffer>>8;
  *(DataArryPoint+2)=Buffer>>16;
  *(DataArryPoint+3)=Buffer>>24;
  RdStartAdd +=4;
  DataArryPoint +=4;
 }
}
void ReadDataArry2(unsigned int RdStartAdd,unsigned int DataLength,volatile unsigned int *DataArryPoint)
{
 unsigned int i,Buffer;

 for(i=0;i<DataLength;i++)
 {
  Buffer = *(volatile unsigned int *)RdStartAdd;
  *DataArryPoint = Buffer;
  RdStartAdd += 4;
  DataArryPoint += 1;
 }
}





void ReadDataArry_U8(unsigned int RdStartAdd,unsigned int DataLength,volatile unsigned char *DataArryPoint)
{
 unsigned int i;
 for (i=0;i<DataLength;i++)
 {
  if((i!=0)&&(i%4==0))
  {
   RdStartAdd +=4;
  }
  *DataArryPoint=*(U8_T *)(RdStartAdd+ (i%4));
  DataArryPoint++;
 }
}






void IFC_interrupt_CMD(FunctionalStatus NewState ,IFC_INT_TypeDef IFC_INT_x)
{
 if(NewState != DISABLE)
 {
  IFC->IMCR =IFC->IMCR|IFC_INT_x;
 }
 else
 {
  IFC->IMCR =IFC->IMCR & (~IFC_INT_x);
 }
}





void IFC_Int_Enable(void)
{
    IFC->ICR=0Xf007;
 *(volatile UINT32 *) (0xE000E000 +0x100 ) = (0x01ul<<2);
}






void IFC_Int_Disable(void)
{
    *(volatile UINT32 *) (0xE000E000 +0x180 ) = (0x01ul<<2);
}
